package com.itheima.Day11.ZuoYe.ZuoYe2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class Test2 {
    public static void main(String[] args) {
        try(FileReader fr = new FileReader("D:\\javajc_ws\\javaEE\\src\\com\\itheima\\Day11\\ZuoYe\\ZuoYe2\\ceshi.txt");
            BufferedReader br = new BufferedReader(fr);){
            String line = br.readLine();
            int i = Integer.parseInt(line);

            if(i <= 3&& i > 0){
                System.out.println("欢迎使用本软件,目前还剩余"+i+"次使用免费");
                i--;
                BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\javajc_ws\\javaEE\\src\\com\\itheima\\Day11\\ZuoYe\\ZuoYe2\\ceshi.txt"));
                bw.write(i+"");
                bw.flush();
                bw.close();
            }else if(i == 0){
                System.out.println(("本软件只能免费试用3次，欢迎您注册会员后继续使用"));
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
